<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
 <% String path = request.getContextPath();%>
<!DOCTYPE html>
<html lang="en">
<title>管理员登录</title>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Tabib Apps web | Admin Dashboard Template</title>
    <!-- Favicon icon -->
    <link rel="icon" type="image/png" href="<%=path %>/assets/images/favicon-32x32.png">
    <!-- Base Styling  -->
    <link rel="stylesheet" href="<%=path %>/assets/main/css/fonts.css">
    <link rel="stylesheet" href="<%=path %>/assets/main/css/style.css">
</head>

<body>
    <div id="main-wrapper" class="show">

        <div class="login-tabib">
            <div>
                <div class="text-center">
                    <a class="logo" >
                        <img class="img-fluid" src="<%=path %>/assets/images/logo.png" alt="loogin page">
                    </a>
                </div>
                <div class="login-main">
                    <form class="theme-form" id="addFrom"  method="post">
                    <style>
                    	.regSuccess {
	text-align: center;
	margin-top: 30px;
	font-size: 10px;
	font-weight: 600;
	color: #DC143C;
}
                    </style>
                    				<div class="regSuccess">
										<span id="errorMes"></span>
									</div>
                        <h4>管理员登录</h4>
                       	<div class="form-group m-b-10">
                            <label class="col-form-label pt-0">账户</label>
                            <div class="row g-2">
                                <div class="col-md-12 col-lg-6">
                                    <div class="form-group mb-0">
                                        <input class="form-control" type="text" placeholder="First name" id="account" name="username">
                                    </div>
                                </div>
                                
                            </div>
                        </div>
                       
                        <div class="form-group m-b-10">
                            <label class="col-form-label">密码</label>
                            <div class="form-input position-relative">
                                <input class="form-control" type="password" placeholder="pass word" id="password" name="password">
                                <div class="show-hide"><span class="show"></span></div>
                            </div>
                        </div>
                        <div class="form-group mb-0">
<!--
                            <div class="checkbox p-0">
                                <input id="checkbox1" type="checkbox">
                                <label class="text-muted" for="checkbox1">Agree with<a class="ms-2 text-primary"
                              href="#">Privacy Policy</a></label>
                            </div>
-->
                            <button class="btn btn-primary w-100" id="btnLogin" type="button">登录</button>
                        </div>
<!--
                        <p class="mt-4 mb-0">Already have an account?<a class="ms-2 text-primary" href="page-login.html">Sign in</a>
                        </p>
-->
                    </form>
                </div>
            </div>
        </div>

    </div>

    <!-- JQuery v3.5.1 -->
    <script src="<%=path %>/assets/plugins/jquery/jquery.min.js"></script>

    <!-- popper js -->
    <script src="<%=path %>/assets/plugins/popper/popper.min.js"></script>

    <!-- Bootstrap -->
    <script src="<%=path %>/assets/plugins/bootstrap/js/bootstrap.js"></script>

    <!-- Moment -->
    <script src="<%=path %>/assets/plugins/moment/moment.min.js"></script>

    <!-- Main Custom JQuery -->
    <script src="<%=path %>/assets/js/toggleFullScreen.js"></script>
    <script src="<%=path %>/assets/js/main.js"></script>

</body>
<script src="<%=path %>/js/jquery-3.6.0.min.js"></script>
<script type="text/javascript">
var path = "${pageContext.request.contextPath}";  

function checkLogin(){
	var account = $("#account").val();
	var password = $("#password").val();
	$.ajax({
		url:path+"/ManagerController?action=toLogin",
		type:"post",
		data:{"account":account,"password":password},
		success : function(data){
			if("have"==data){
				location.href=path+"/web/manager/index.jsp";
			}
			else{
				$("#errorMes").css("color", "red");
				$("#errorMes").html("账号或密码错误，请重新输入！");
				return false;
			}
		}
	});
}

	$(function(){
		$("#btnLogin").on("click",checkLogin);
	})
</script>
</html>